package com.gitee.ywj1352.pservlet.tag;

import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
import java.io.StringWriter;

/**
 * 自定义 Tag
 * @author: yangwenjie.a
 * @date: 2021/7/6 13:31
 * @description:
 */
public class MyTag extends SimpleTagSupport {

    private String message;
    private String color;

    public void setMessage(String msg) {
        this.message = msg;
    }

    public void setColor(String color) {
        this.color = color;
    }

    StringWriter sw = new StringWriter();

    @Override
    public void doTag() throws JspException, IOException {
        JspContext jspContext = getJspContext();
        JspWriter out = jspContext.getOut();
        String outStr = String.format("<p style=\"color:%s\">%s</p>", color, message);
        out.println(outStr);
    }

}
